package kr.co.happenstance.adapter;

import java.util.ArrayList;

import kr.co.happenstance.R;
import kr.co.happenstance.lib.vo.PayLogResultVo.PayLog;
import kr.co.happenstance.util.Util;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PayLogAdapter extends BaseAdapter {
	protected final String TAG = "<<<PayLogAdapter>>>";
	
	private LayoutInflater inflater = null;
	private ArrayList<PayLog> payLogList;
	private ViewHolder viewHolder = null;
	
	public PayLogAdapter(Context context, ArrayList<PayLog> _list){
		this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.payLogList = _list;
	}
	
	@Override
	public int getCount() {
		return this.payLogList.size();
	}

	@Override
	public Object getItem(int position) {
		return payLogList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		try{
			if(v == null){
				 v = inflater.inflate(R.layout.adapter_paylog, parent, false);
				 viewHolder = new ViewHolder();
				 viewHolder.tvPrice = (TextView) v.findViewById(R.id.tv_price);
				 viewHolder.tvDate = (TextView) v.findViewById(R.id.tv_date);
				 v.setTag(viewHolder);
			}else{
				viewHolder = (ViewHolder)v.getTag();
			}
			
			viewHolder.tvPrice.setTag(Integer.toString(position));
			viewHolder.tvPrice.setText(Util.getCurrencyFormat(payLogList.get(position).payAmount));
			
			viewHolder.tvDate.setTag(Integer.toString(position));
			viewHolder.tvDate.setText(payLogList.get(position).regDate);
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return v;
	}	

	
	private class ViewHolder{
		public TextView tvPrice = null;
		public TextView tvDate = null;
	}






}
